FROM golang:1.17-alpine AS builder
ENV GO111MODULE=on
# ENV GOPROXY=https://goproxy.cn,direct
WORKDIR /build

COPY go.mod .
COPY go.sum .

RUN go mod tidy

COPY . .

RUN go build -o ./chat .

FROM alpine
WORKDIR /

ENV MYSQL_PATH=mysql:3306
ENV MYSQL_USER=root
ENV MYSQL_PASSWORD=123456
ENV REDIS_PATH=redis:6379
ENV REDIS_USER=root
ENV REDIS_PASSWORD=""


COPY --from=builder /build/chat /

EXPOSE 16012

CMD ["/chat"]





# FROM golang:latest
# ENV MYSQL_PATH=mysql:3306
# ENV MYSQL_USER=root
# ENV MYSQL_PASSWORD=123456
# ENV REDIS_PATH=redis:6379
# ENV REDIS_USER=root
# ENV REDIS_PASSWORD=""
# ENV GO111MODULE=on
# ENV GOPROXY=https://goproxy.cn,direct
# WORKDIR /app/chat

# COPY go.mod .
# COPY go.sum .

# RUN go mod tidy

# COPY . .

# RUN go build -o ./main.go .

# EXPOSE 16012:16012

# CMD ["./main.go"]